/********************************************************************
***	Author : Franck Tomeba
*** 	Coprocessor Simulation 2
***	Write Some Values in Register
***	Read and print the value stored in the registers
********************************************************************/
#include "TestApp.h"
#include "stdio.h"

int main(void)
{
	unsigned int value;
	int offset;
	
	
	print("\n\rCoprocessor Simulation 3");
	print("\n\rWrite an Read Values From Registers");
	
	print("\n\n\rWrite  0x1B in Monitoring Length Reg");
	write_reg(OFFSET_MON_LEN, 0x0000001B);
	value = read_reg(OFFSET_MON_LEN);
	print("\n\rRead : ");
	putnum(value);
	
	print("\n\n\rWrite 0x0B in Scan Period Reg");
	write_reg(OFFSET_SCAN_PERIOD, 0x0000013B);
	value = read_reg(OFFSET_SCAN_PERIOD);
	print("\n\rRead : ");
	putnum(value);

	print("\n\n\rWrite 0x05 in Configuration Reg");
	write_reg(OFFSET_GW_CONFIG, 0x00000005);
	value = read_reg(OFFSET_GW_CONFIG);
	print("\n\rRead : ");
	putnum(value);
	
	print("\n\n\rWrite 3=STOP in Command Reg");	
	write_reg(OFFSET_CMD, 0x00000003);
	value = read_reg(OFFSET_CMD);
	print("\n\rRead : ");
	putnum(value);
	
	for( offset=0; offset <=48; offset += 4)
	{
		print("\n\n\rWrite 1 in Register ");
		putnum(offset);
		write_reg(offset, 0x00000001);
		value = read_reg(offset);
		print("\n\rRead : ");
		putnum(value);
		
	}
	write_reg(OFFSET_CMD, CMD_NOP);

	return 1;
}
